package br.com.felix.clearcase.command;

import java.io.File;

import br.com.felix.easyclearcase.EasyClearCaseFile.ClearCaseStatus;

/**
 * This command encapsulates the cleartool command ls.
 * */
public class ListFiles extends ClearToolCommand {
	
	
	private boolean recurseDirectories = false;
	
	private boolean directoryOnly = false;
	
	
	/**
	 * Instantiates a new command.
	 * @param workingDirectory is the directory that you wish the list the files of.
	 * */
	public ListFiles(File workingDirectory){
		setWorkingDirectory(workingDirectory);
	}
	
	
	/**
	 * @see ClearToolCommand#toCommandLine()
	 * */
	@Override
	public String toCommandLine() {
		return "cleartool ls "+(recurseDirectories?" -recurse ":" ")+(directoryOnly?" -directory ":" ")+ " -s";
	}


	
	public boolean isRecurseDirectories() {
		return recurseDirectories;
	}


	
	/**
	 * Sets the command to list all the files in the directory's hierarchy (subfolders).
	 * */
	public void setRecurseDirectories(boolean recurseDirectories) {
		this.recurseDirectories = recurseDirectories;
	}


	/**
	 * Sets the command to list directories only in the output.
	 * */
	public void setDirectoryOnly(boolean dirOnly) {
		directoryOnly = dirOnly;
	}


	@Override
	public String getCommandName() {
		return "List files";
	}


	@Override
	public ClearCaseStatus getStatusAfterExecution() {
		return null;
	}
}
